package com.ruoyi.mapper;


import com.ruoyi.domain.AdvIncomedetail;
import com.ruoyi.domain.Vo.InComeDetailResponse;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 【请填写功能名称】Mapper接口
 *
 * @author ruoyi
 * @date 2024-05-13
 */
public interface AdvIncomedetailMapper
{
    @Delete("delete from  adv_incomedetail " +
            "where adv_income_id in " +
            "(select adv_income_id  from adv_income)")
    public int clear();

    @Delete("delete from  adv_incomedetail " +
            "where adv_income_id in " +
            "(select adv_income_id  from adv_income where adv_members_id=#{advMembersId})")
    public int deleteByAdvMembersId(@Param("advMembersId") String advMembersId);

    /**
     * 查询【请填写功能名称】
     *
     * @param advIncomedetailId 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    public AdvIncomedetail selectAdvIncomedetailByAdvIncomedetailId(Long advIncomedetailId);

    /**
     * 查询【请填写功能名称】列表
     *
     * @param advIncomedetail 【请填写功能名称】
     * @return 【请填写功能名称】集合
     */
    public List<AdvIncomedetail> selectAdvIncomedetailList(AdvIncomedetail advIncomedetail);

    /**
     * 新增【请填写功能名称】
     *
     * @param advIncomedetail 【请填写功能名称】
     * @return 结果
     */
    public int insertAdvIncomedetail(AdvIncomedetail advIncomedetail);

    /**
     * 修改【请填写功能名称】
     *
     * @param advIncomedetail 【请填写功能名称】
     * @return 结果
     */
    public int updateAdvIncomedetail(AdvIncomedetail advIncomedetail);

    /**
     * 删除【请填写功能名称】
     *
     * @param advIncomedetailId 【请填写功能名称】主键
     * @return 结果
     */
    public int deleteAdvIncomedetailByAdvIncomedetailId(Long advIncomedetailId);

    /**
     * 批量删除【请填写功能名称】
     *
     * @param advIncomedetailIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAdvIncomedetailByAdvIncomedetailIds(Long[] advIncomedetailIds);

    List<AdvIncomedetail> getIncomedetail(@Param("advIncomeId") String advIncomeId);

    List<AdvIncomedetail> getNextInComedetail(@Param("advMembersId") String advMembersId);

    int deleteByAdvIncomeIds(Long[] advIncomeIds);

    @Select("select sum(pay_amount) " +
            "from adv_income where  adv_members_id=#{advMembersId} and is_audit=1")
    String getIncome(@Param("advMembersId") Long advMembersId);

    @Select("select cal_mode as calMode, " +
            "cal_year as calYear, cal_month as calMonth, cal_date as calDate," +
            "adv_income_id as advIncomeId, pay_amount as payAmount, audit_date as auditDate, " +
            "total_amount as totalAmount, total_amount_sub as totalAmountSub " +
            "from " +
            "adv_income " +
            "where " +
            "adv_members_id=#{advMembersId} and is_audit=1")
    List<InComeDetailResponse> getIncomeDetail(Long advMembersId);
}
